package com.vinfai.thread.tradition;

public class JoinTest {
		
	public static void main(String[] args){
		MyThread t1 = new MyThread();
		//t1.setDaemon(true);
		t1.start();
		for(int i=0;i<20;i++){
			System.out.println("MAIN THREAD : "+i+" !");
			if(i>2){
				try {
					t1.join();//当前线程将CPU让个T1线程.
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				
			}
		}
	}
}

class MyThread extends Thread{
	
	@Override
	public void run(){
		for(int i=0;i<10;i++){
			System.out.println("THREAD1 RES: "+i+" !");
		}
	}
}
